package game.leon.war.node.handler;

import game.leon.war.defs.MessageConsts;
import game.leon.war.defs.Vo;
import game.leon.war.node.handler.letter.NodeLetter;
import game.leon.war.node.service.MessageDispatcher;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 战斗周期事件
 * User: bianpeng
 * Date: 12-2-8
 */
@Component
public class BattleTickHandler implements Handler<NodeLetter, Vo.SuccessVO>{
    private Logger logger = Logger.getLogger(getClass());
    @Autowired
    private MessageDispatcher dispatcher;
    @Override
    public Vo.SuccessVO exec(long userId, NodeLetter letter) {
        logger.info("battle tick: " + userId);
        dispatcher.dispatch(new NodeLetter(userId, MessageConsts.BATTLE_TICK, letter.getExpiredTime()+1000));
        return null;
    }
}
